<template>
  <div>
    <nav class="nav">
      <ul flex="box:mean">

        <li v-for="item in tabs" :class="{ active: item.tab === ($route.query.tab || '') }">
          <router-link :to="{ name: 'index', query: { tab: item.tab } }">{{ item.title }}</router-link>
        </li>
      </ul>
    </nav>

    <v-content v-vuet-scroll="{ path: 'topic-list', name: 'content' }">

	   <div class="_full_inner _scroll _effect component-chat" :class="{'_effect--30':decline}">
		<ul class="wechat-list">
            <li class="item _line-fine" v-for="item in data.list" key="item.id" transition="chat-item">
                <div class="info">

          	     <router-link :to="{ name: 'user-detail', params: { username: item.author.loginname } }">
                    <div class="ico-box">
                        <i class="_news-count" v-if="item.reply_count != '0'">{{item.reply_count}}</i>
                        <div class="ico">
                            <img :src="item.author.avatar_url" alt="pic">
                        </div>

                        <div class="ico_title">
                            {{item.tab=='go'?'出行':''}}
                            {{item.tab=='clothes'?'靓衣':''}}
                            {{item.tab=='buy'?'跳蚤':''}}
                            {{item.tab=='travel'?'旅游':''}}
                            {{item.tab=='house'?'房产':''}}
                            {{item.tab=='joke'?'段子':''}}
                            {{item.tab=='beauty'?'美女':''}}
                        </div>
                    </div>
          	     </router-link>

          	     <router-link :to="{ name: 'topic-detail', params: { id: item.id } }">
                    <div class="desc">
                        <div class="desc-time">{{item.last_reply_at | formatDate}}</div>
                        <div class="desc-title" v-text="item.author.loginname.substring(29)"></div>
                        <div class="desc-message">
                            <span v-text="item.title.split('|')[0].substring(0, 46)"></span>
                        </div>
                        <div class="desc-message">
                            <span v-text="item.title.split('|')[1]"></span>
                        </div>

						<div v-if="item.pic_list != null && item.pic_list.length != null">
							<div class="post" v-if="item.pic_list.length == 1">	
								<img :src="item.pic_list[0].slice(1, -1)" alt="pic">
							</div>
							
							<div class="post" v-if="item.pic_list.length >= 2">	
								<img :src="item.pic_list[0].slice(1, -1)" alt="pic" class="list-img">
								<img :src="item.pic_list[1].slice(1, -1)" alt="pic" class="list-img">
								<img :src="item.pic_list[2].slice(1, -1)" alt="pic" class="list-img" v-if="item.pic_list.length >= 3">
							</div>
						</div>

                    </div>
          	        </router-link>
                </div>

			   <div style="border-bottom: 1px solid #e6ebf1;"></div>
            </li>
        </ul>
	  </div>

		<!--
        <div v-for="item in data.list" key="item.id">
          <router-link :to="{ name: 'topic-detail', params: { id: item.id } }">

			  <wv-cell class="cell-big-thumb" :value="item.last_reply_at | formatDate">
				<div slot="icon" style="position: relative;margin-right: 5px;">
				<img :src="item.author.avatar_url" style="width: 48px; height: 48px;border-radius: 5px;display: block">
				<wv-badge v-if="item.reply_count" style="position: absolute;top: -.4em;right: -.4em;">{{ item.reply_count > 0 ? item.reply_count : '0' }}</wv-badge>
				</div>
				<template slot="bd">
				<p style="font-size: 16px;color: #000000;">{{item.author.loginname.substring(29)}}</p>
				<p style="font-size: 14px;color: #888888;">{{item.title.split("|")[0].substring(0, 46)}}</p>
				<p style="font-size: 14px;color: #888888;">{{item.title.split("|")[1].substring(0, 46)}}</p>
				</template>
			  </wv-cell>

			   <div style="border-bottom: 1px solid #e6ebf1;"></div>

          </router-link>
        </div>
		-->

      	<v-loading :done="data.done" :loading="data.loading" @seeing="data.fetch()"></v-loading>
    </v-content>
    <v-footer></v-footer>
  </div>
</template>
<script>
  import { mapModules, mapRules } from 'vuet'

  export default {
    mixins: [
      mapModules({ data: 'topic-list', weixin:'weixin-api' }),
      mapRules({ route: 'topic-list' })
    ],
    data () {
      return {
        tabs: [
          {
            title: '全部',
            tab: ''
          },
		  {
            title: '出行',
            tab: 'go'
          },
          {
            title: '跳蚤',
            tab: 'clothes'
          },

          {
            title: '旅游',
            tab: 'travel'
          },
          {
            title: '房产',
            tab: 'house'
          },
          {
            title: '段子',
            tab: 'joke'
          },
		  {
            title: '美女',
            tab: 'beauty'
          }
        ]
      }
    },
    created: function () {
		console.log(this.$route.params.id);
		this.weixin.share("主页", "http://m.doubilol.com/logo.jpg");
	},
  }
</script>
<style lang="less" scoped>
  @import "../../less/config";
  .nav {
    position: absolute;
    background: #fff;
    top: 0;
    right: 0;
    left: 0;
    z-index: 10;
    border-bottom: 1px solid #ddd;
    ul {
      overflow: hidden;
      padding: 0;
      margin: 0;
      li {
        position: relative;
        list-style: none;
        line-height: 49px;
        text-align: center;
      }
      a {
        display: block;
        text-decoration: none;
        font-size: 14px;
        color: lighten(@text, 50%);
      }
      .active {
        &:after {
          content: "";
          position: absolute;
          right: 0;
          left: 0;
          bottom: 1px;
          z-index: 1;
          height: 3px;
          background: @main;
        }
        a {
          color: @text;
        }
      }
    }
  }


  .list {
    overflow: hidden;
    padding: 0;
    margin: 0;
    background: #eee;
    li {
      position: relative;
      padding: 15px 15px 0 15px;
      margin-bottom: 15px;
      list-style: none;
      box-shadow: 0 0 5px #ccc;
      background: #fff;
    }
    .top {
      height: 40px;
      .headimg {
        overflow: hidden;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        border: 1px solid #ddd;
        background-position: center center;
        background-size: cover;
      }
      .box {
        padding-left: 5px;
        strong {
          line-height: 24px;
          font-size: 16px;
          font-weight: normal;
          color: darken(@text, 10%);
        }
        time {
          line-height: 16px;
          font-size: 12px;
          font-style: normal;
          color: #aaa;
        }
        .tag {
          margin-left: 4px;
          line-height: 16px;
          font-size: 12px;
          font-style: normal;
          color: @main;
        }
      }
    }
    .tit {
      padding: 10px 0;
      line-height: 22px;
      font-size: 16px;
      font-weight: bold;
      color: @text;
    }
  }


  .expand {
    padding: 10px 0;
    border-top: 1px solid #e1e1e1;
    text-align: center;
    .item {
      padding: 0 10px;
      line-height: 20px;
      text-align: center;
      border-right: 1px solid #e1e1e1;
      &:last-of-type {
        border: none;
      }
      .iconfont {
        color: #aaa;
      }
      .num,
      .time {
        padding-left: 3px;
        font-size: 12px;
        color: #aaa;
      }
      .pic,
      img {
        width: 16px;
        height: 16px;
        background: #e1e1e1;
        background-size: cover;
        background-position: center center;
      }
      .pic {
        overflow: hidden;
        border-radius: 50%;
      }
    }
  }


.component-chat .wechat-list {
    position: relative;
    overflow-x: hidden;
    padding: 10px 0;
}

.component-chat .wechat-list .info {
    transition: .2s all linear;
	min-height:80px;
}

.component-chat .wechat-list .item .info.current {
    transform: translate3d(-156px, 0, 0);
    -webkit-transform: translate3d(-156px, 0, 0);
}

.component-chat .wechat-list .item .info:active {
    background-color: #d9d9d9;
}

.component-chat .wechat-list .item {
    position: relative;
}

.component-chat .wechat-list .item:last-child:after {
    content: "";
    position: absolute;
    width: 200%;
    left: 0;
    z-index: 2;
    left: 8px;
    bottom: 0;
    transform: scale(.5);
    transform-origin: 0 0;
    -webkit-transform: scale(.5);
    -webkit-transform-origin: 0 0;
    background-color: #b7b7b7;
    height: 1px;
}

.component-chat .wechat-list .info {
    position: relative;
    z-index: 2;
    left: 0;
    width: 100%;
    padding: 8px;
    background-color: #ffffff;
    transition: .2s transform linear;
}

.component-chat .wechat-list .info--stick {
    background-color: #f2f2f6;
}

.component-chat .wechat-list .info .ico-box {
    position: relative;
    float: left;
    width: 48px;
    height: 48px;
    margin-right: 10px;
    /* background: #d6d5d3; */
}

.component-chat .wechat-list .info .ico {
    height: 100%;
    border-radius: 5px;
    overflow: hidden;
}

.component-chat .wechat-list .info .ico img {
    width: 100%;
    border: 0;
}

.ico_title {
    text-align : center;
    background: #ff7575 url(/images/alert-overlay.png) repeat-x;
    display: inline-block;
    padding: 1px 10px 1px;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    line-height: 1;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    position: relative;
    cursor: pointer; 
}

.component-chat .wechat-list .info .desc {
    overflow: hidden;
}

.component-chat .wechat-list .info .desc-time {
    float: right;
    color: #b2b2b2;
	padding-right: 12px;
}

.component-chat .wechat-list .item .handle {
    position: absolute;
    z-index: 1;
    height: 100%;
    right: 0;
    top: 0;
    display: flex;
}

.component-chat .wechat-list .item .handle>div {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #c7c7cc;
    color: #ffffff;
    font-size: 18px;
    padding: 0 12px;
}

.component-chat .wechat-list .item .handle .handle-del {
    background-color: #ff3b30;
}

.component-chat .wechat-list .desc-title {
    height: 25px;
    line-height: 25px;
    font-size: 18px;
    color: #000;
}

.component-chat .wechat-list .desc-message {
    --height: 23px;
    max-height: 69px;
    line-height: 23px;
    font-size: 16px;
    color: #888888;
}

.component-chat .wechat-list .desc-message {
    --height: 23px;
    max-height: 69px;
    line-height: 23px;
    font-size: 14px;
    color: #888888;
}

.component-chat .wechat-list .info .desc-mute {
    float: right;
    color: #b8b8b8;
    font-size: 14px;
}

.component-chat .wechat-list .info.active .desc-mute {
    color: #b9b9b9;
}

.component-chat ._line-fine:before {
    z-index: 3;
    left: 8px;
}

.component-chat .chat-item-transition {
    --height: 64px;
    transition: .3s height ease;
}

.component-chat .chat-item-leave {
    height: 0;
    overflow: hidden;
}


/*聊天详情*/

.chat-dialogue-entry-collect {
    background-color: #ffffff;
    position: relative;
    padding: 15px 10px 5px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
    color: #464646;
    font-size: 14px;
}

.chat-dialogue-entry-collect li {
    float: left;
    flex-grow: 1;
    flex-basis: 25%;
    max-width: 25%;
    padding: 5px 10px;
    text-align: center;
}

.chat-dialogue-entry-collect li div.pic {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    width: 55px;
    height: 55px;
    margin: 0 auto;
    background-size: cover;
}

.chat-dialogue-entry-collect li p.username {
    padding-top: 5px;
}

.chat-dialogue-entry-collect li:last-child div.pic {
    border-radius: 0;
}

.chat-dialogue-entry-collect li:last-child div.pic div {
    position: absolute;
    left: 0;
    top: 0;
    width: 200%;
    height: 200%;
    border: 1px solid #bbb;
    border-radius: 12px;
    transform: scale(.5);
    transform-origin: 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-dialogue-entry-collect li:last-child div.pic span.iconfont {
    font-size: 70px;
    color: #bbbbbb;
}

.component-chat-detail .chat-dialogue-entry-collect::before {
    content: "";
    position: absolute;
    width: 200%;
    left: 0;
    bottom: 0;
    transform: scale(.5);
    transform-origin: 0 0;
    -webkit-transform: scale(.5);
    -webkit-transform-origin: 0 0;
    background-color: #b7b7b7;
    height: 1px;
    z-index: 2;
}

.parentheses {}

.parentheses:before {
    content: "(";
}

.parentheses:after {
    content: ")";
}

._news-count {
    position: absolute;
    font-style: initial;
    font-family: PingFang SC, Hiragino Sans GB, Arial, Microsoft YaHei, Helvetica;
    right: -9px;
    top: -5px;
    z-index: 2;
    padding: 0 4px;
    width: auto;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    color: #ffffff;
    text-align: center;
    font-size: 14px;
    background-color: #f43531;
}

.post .list-img {
    width: 30%;
    height: 80px;
    width: 80px;
    padding-right: 5px;
    float: left;
    object-fit: cover;
}

.post img {
    padding: 10px 5px 0 0;
    display: block;
	min-height:80px;
	min-width:80px;
    max-height: 130px;
    max-width: 130px;
}
</style>
